#!/bin/bash

# edit pre-commit, add following line
#${REPOS}/hooks/check_txn_size.sh "$REPOS" "$TXN" || exit 1


LIMIT_SIZE=1024000
SVNLOOK=svnlook

REPOS="$1"
TXN="$2"


files=`$SVNLOOK changed -t "$TXN" "$REPOS" | awk '{print $2}'`
for f in $files
do
    # low version svnlook hasn't filesize subcommand
    filesize=`$SVNLOOK cat -t "$TXN" "$REPOS" "$f" | wc -c`
    if [ $filesize -ge $LIMIT_SIZE ]; then
        echo "$f ($filesize bytes) is larger than the limit $LIMIT_SIZE bytes" 1>&2
        exit 1
    fi
done

exit 0
